package com.leo.boot.aop.service;

import com.leo.boot.aop.annotation.Lock;
import com.leo.boot.aop.annotation.Safe;
import com.leo.boot.aop.domain.MockUser;
import lombok.SneakyThrows;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class MockUserService {

    @Resource
    MockUserService self;

    @Lock(id = "#user.id")
    @SneakyThrows
    public boolean update(MockUser user) {
        return true;
    }

    @Safe
    @SneakyThrows
    public MockUser exception(MockUser user) {
        throw new RuntimeException("test");
    }

    public MockUser intercept(MockUser user) {
        return user;
    }

    public MockUser intercept() {
        return null;
    }

    public MockUser safe(MockUser user) {
        return self.exception(user);
    }
}
